-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
src: remove Environment::GetCurrent(isolate) #58311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
3f4dfa8
to
9a1be50
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58311 +/- ##
==========================================
- Coverage 90.21% 89.68% -0.54%
==========================================
Files 633 633
Lines 186834 186832 -2
Branches 36683 36363 -320
==========================================
- Hits 168549 167556 -993
- Misses 11089 12023 +934
- Partials 7196 7253 +57
🚀 New features to boost your workflow:
|
9a1be50
to
ea46cf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defensively marking this semver-major as this may be an ABI-breaking changing. Environment
is used via node.h
and directly depended on by native addons that might be using this method. Instead of removing right away we likely need to take it through a proper deprecation cycle.
Putting the red x on this until the possible downstream impact can be determined.
While that is true, native addons do make use of |
Can you post a couple examples ? |
I see that most usage comes from Electron. Although, this might look like a breaking change, this function isn't exposed using similar. I wonder if semver-major holds for functions that are not publicly exposed. The reason I want to remove this because this is an anti-pattern. Removing isolate constructor, and accessing through isolate's context gives the same outcome, but gives the option to create a handleScope or not, to the user. My 2 cents, it to move forward with this, and later put environment into slow/fast path callback data, and eventually getting rid of similar usages (and potentially limiting the creation scope of environment object) @nodejs/tsc any input is appreciated |
It's not clear to me that there are legitimate native addons in the search result. I only see Node.js source code and Electron source code. |
Electron's use doesn't count? At this point I'm not comfortable lifting my -1 on this. I think it should go through at least a deprecation cycle (deprecate now, removed only after the next major release) |
If the idea is to avoid creating the HandleScope don't think the changes here do the job
The HandleScope is needed because the
I think the anti-pattern is to require an Environment when all the binding needs is only the isolate, or the context. If the binding really needs an Environment/the context (many of the code being touched here do) then a HandleScope must still be created to hold |
@@ -16,7 +16,7 @@ AsyncResource::AsyncResource(Isolate* isolate, | |||
Local<Object> resource, | |||
const char* name, | |||
async_id trigger_async_id) | |||
: env_(Environment::GetCurrent(isolate)), | |||
: env_(Environment::GetCurrent(isolate->GetCurrentContext())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, this is not doing what the comment above claims. The code here still needs the Environment, therefore it still needs to look it up from the context, therefore it still needs a HandleScope. It's not up to the caller to choose to create it or not - if it doesn't, V8 can just crash.
Removes
Environment::GetCurrent(isolate)
callscc @nodejs/cpp-reviewers